home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1992 June: ROMin Holiday / ADC Developer CD (1992-06) (''ROMin Holiday'')_iso / Developer Connection - 06-1992.iso / Development Platforms / LISP Related / HyperQ. Plastics / plysel0625 < prev    next >
Encoding:
Text File  |  1991-11-08  |  4.8 KB  |  174 lines  |  [TEXT/AAIS]

  1. /*  PLAMSELP:  HyperExpert for plastic material and process selection.   
  2.  
  3.     Copy Right:  Life-cycle Engineering Group at Ohio State University (LEGOS)
  4.     Authors:  K. Beiter, K. Ishii, S. Krizan, L. Hornberger (Apple)
  5.     HyperCard / IM support:  Steven Weyer, Ruben Kleiman  (Apple, ATG)
  6.     
  7.       Revision record:
  8.        6/24/90   Version 1.0  Commented.  Good for 70 materials
  9.                  Use "findall"  instead of "findall" when running this program under AAIS prolog
  10.                  Convert to IM code using IM convert, name it rules.p
  11.                  then, use with PLAMSELP stack and PLASTICS stack, also with data.p 
  12.                  IM version must use "findall"
  13.                  
  14.                  */
  15.         
  16. /*  6/12/90  Since max_val_asserting takes a lot of time, we decided to assert arbitrary
  17. Values here.  Future version should do this in HyperTalk and add it to data.p rather
  18. than rules.p */
  19.  
  20. max_val_prop_asserted(uts, 12000.01, max).
  21. max_val_prop_asserted(izod, 15.01, max).
  22. max_val_prop_asserted(hdt, 400.01, max).
  23. max_val_prop_asserted(spec_grav, 5.01, max).
  24. max_val_prop_asserted(tms, 5.01, max).
  25.  
  26. /* sub_points fetches the attribute value of an attribute, normalizes it with the
  27. maximum attribute value out of the polymer set, then multiplies it with a coefficient. */
  28.         
  29. sub_points(Polyname, Att, Score)
  30.     :-  attribute(Att, Polyname, Rawscore),
  31.         max_val_prop_asserted(Att, MaxVal, MaxPlyname),
  32.         coeff(Att, Num),
  33.         Score is Rawscore *Num/ MaxVal.
  34.  
  35. total_points(Polyname, Name_and_score)
  36.     :-  attribute_set(List_of_attributes),
  37.         total_points_aux(Polyname, List_of_attributes, Name_and_score).
  38.         
  39. total_points_aux(Polyname,[],0.001).
  40. total_points_aux(Polyname,[First|Rest], Score)
  41.     :-  total_points_aux(Polyname,Rest, Rscore),
  42.         sub_points(Polyname, First, Subscore),
  43.         Score is Rscore + Subscore.
  44.         
  45.         
  46. % this predicate checks to see if a particular material meets the minimum requirment Att
  47.             
  48. qualify(Mat_name, Att, Min_req_val)
  49.     :- attribute(Att, Mat_name, Att_val),
  50.         X is Att_val + 1000.021,
  51.         Y is Min_req_val + 1000.021,
  52.         X >= Y.
  53.         
  54. /*  this predicate tries to see if a material meets minimum values for a list of attributes,
  55. and returns a list of attribute names and corresponding values.
  56. */
  57.         
  58. qualify_list(Mat_name, []).
  59. qualify_list(Mat_name, [(Att, Min_req_val)|Rest_of_att_and_minval])
  60.     :-  qualify(Mat_name, Att, Min_req_val),
  61.         qualify_list(Mat_name, Rest_of_att_and_minval).
  62.         
  63.  
  64. /*  Rev. 6/24/90 quant_prune is no longer used  */
  65.  
  66. /*  cutoff_assert asserts a list of cutoffs (Att_name, Mininum requirement) as read from 
  67. HyperExpert */
  68.  
  69. cutoff_assert
  70.     :- findall((Att_name, Min_req), cutoff(Att_name, Min_req), List_of_cutoffs),
  71.         assertz(qual_list(List_of_cutoffs)).
  72.  
  73.         
  74. /*  Actual triggers for qualitative  */
  75.  
  76.         
  77. doit4(Ans)
  78.     :- findall((Polyname), candidate(Polyname), List_of_polymers),
  79.         doit41(List_of_polymers, Ans).
  80.         
  81. /*  candidate gives a prunes list of Polymers  */
  82. candidate(Polyname)
  83.     :- polymer(Type, Polyname),
  84.         ok_by_type(Type),
  85.         ok_by_cutoffs(Polyname).
  86.  
  87. ok_by_type(Type)
  88.     :- 
  89.         type_list(Type_list),
  90.         mymember(Type, Type_list).
  91.  
  92. ok_by_cutoffs(Polyname)
  93.     :- 
  94.         qual_list(List_of_cutoffs),
  95.         qualify_list(Polyname, List_of_cutoffs).
  96.         
  97. doit41([],[]).
  98. doit41([First|Rest], [(First,Fans)|Rans])
  99.     :- total_points(First, Fans),
  100.         doit41(Rest, Rans).
  101.         
  102. doit5 :- doit4(Ans), plist(Ans).
  103.  
  104. doit6(Num, Final_ans)
  105.     :- doit4(Unsorted_ans),
  106.         quicksort(Unsorted_ans, Sorted_ans),
  107.         truncate_list(Num, Sorted_ans, Final_ans).
  108.         
  109. doit7(Q)
  110.     :- doit6(Q, Final_ans),
  111.         plist(Final_ans).
  112.  
  113. /*  Actual triggers for quantitative stuff  */
  114.  
  115.  
  116. /*  utilities  */
  117. plist([]).
  118. plist([First|Rest]):- write(First), nl,plist(Rest).
  119.  
  120. get_head_of_cons([],[]).
  121. get_head_of_cons([(A,B)|Rest],[A|Grest])
  122.     :- get_head_of_cons(Rest, Grest).
  123.  
  124. get_tail_of_cons([],[]).
  125. get_tail_of_cons([(A,B)|Rest],[B|Grest])
  126.     :- get_tail_of_cons(Rest, Grest).
  127.     
  128. quicksort([],[]).
  129. quicksort([X|Tail],Sorted)
  130.     :-split(X, Tail, Small, Big),
  131.         quicksort(Small, SortedSmall),
  132.         quicksort(Big, SortedBig),
  133.         conc(SortedSmall, [X|SortedBig],Sorted).
  134.  
  135. conc([],L,L).
  136. conc([X|L1],L2, [X|L3])
  137.     :-conc(L1, L2, L3).    
  138.             
  139. split(X, [],[],[]).
  140. split(X, [Y|Tail], [Y|Small], Big)
  141.     :- gt(X, Y), !, split(X, Tail, Small, Big).
  142. split(X, [Y|Tail], Small, [Y|Big])
  143.     :- split(X, Tail, Small, Big).
  144.  
  145. gt((AX, AY), (BX, BY)) 
  146.     :- VY is AY + 1000.021,
  147.         WY is BY + 1000.021,
  148.             VY < WY.
  149.  
  150. truncate_list(Any, [], []).    
  151. truncate_list(0, Ans, []).
  152. truncate_list(N, [F|R], [F|Rans])
  153.     :- N1 is N-1,
  154.         truncate_list(N1, R, Rans).
  155.         
  156. % mymemeber(+element, +set) returns true if the element is a member of the set        
  157. mymember(Element, [Element|Rest]).
  158. mymember(Element, [First|Rest])
  159.     :- mymember(Element, Rest).
  160.  
  161. rev([], Any).    
  162. rev([First|Rest], Ans)
  163.     :- rev(Rest, Rlist),
  164.         myappend(Rlist, [First], Ans).
  165.         
  166. myappend([],L,L).
  167. myappend([X|L1], L2, [X|L3])
  168.     :- myappend(L1, L2, L3).
  169.     
  170. type_list([polycarbonate, abs]).
  171.  
  172. attribute_set([uts, izod, hdt, spec_grav, tms]).
  173.  
  174.